

const useKeyboard = () => {

  document.onkeydown = (e: KeyboardEvent) => {
    
    keyMap[e.key]?.();
  };
  document.onkeyup = (e: KeyboardEvent) => {
    
    if (keyMap[e.key]) {
      e.preventDefault();
    }
  };
  const keyMap: { [key: string]: () => void } = {};
  const debounce: { [key: string]: boolean } = {};

  const register = (key: string, event: () => void) => {
    keyMap[key] = event;
  }

  return {
    register
  }
}

export default useKeyboard;